package com.bush.mall.product.controller;

import org.springframework.web.bind.annotation.*;
import com.bush.mall.common.entity.Result;;
import com.bush.mall.product.entity.AttrEntity;
import com.bush.mall.product.service.AttrService;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 商品属性
 * @author RUN
 * @date 2022-11-28
 */
@RestController
@RequestMapping("attr")
@Api(tags = "商品属性管理" )
public class AttrController {

    @Resource(name= AttrService.BEAN_ID)
    private AttrService attrService;

    /**
     * 分页查询商品属性列表
     * @author RUN
     * @date 2022-11-28
     */
    @ApiOperation(value = "分页查询商品属性列表")
    @GetMapping("queryForPage")
    public Result queryForPage(Integer current,Integer size){
        return attrService.queryForPage(current,size);
    }

    /**
     * 保存商品属性表单
     * @author RUN
     * @date 2022-11-28
     */
    @ApiOperation(value = "保存商品属性表单")
    @PostMapping("saveAttr")
    public Result saveAttr(@RequestBody AttrEntity attr){
        return attrService.saveAttr(attr);
    }

    /**
     * 修改商品属性表单
     * @author RUN
     * @date 2022-11-28
     */
    @ApiOperation(value = "修改商品属性表单")
    @PutMapping("updateAttr")
    public Result updateAttr(@RequestBody AttrEntity attr){
        return attrService.updateAttr(attr);
    }

    /**
     * 通过指定id删除商品属性
     * @author RUN
     * @date 2022-11-28
     */
    @ApiOperation(value = "通过指定id删除商品属性")
    @DeleteMapping("deleteAttr")
    public Result deleteAttr(Long id){
        return attrService.deleteAttr(id);
    }

}
